﻿using GraphLight.Graph;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Collections.Generic;
using GraphLight.Graph2;

namespace GraphLight.Test
{
    [TestClass()]
    public class UndirectedGraphTest
    {
        [TestMethod]
        public void GetShortestWayEdgesTest()
        {
            var graph = new Graph<string, object>();
            var ab = graph.AddEdge("A", "B");
            var bc = graph.AddEdge("B", "C");
            var cd = graph.AddEdge("C", "D");
            ab.Weight = 1;
            bc.Weight = 1;
            cd.Weight = 1;
            var way = graph.GetShortestWayEdges("A", "D");
            Assert.AreEqual(3, graph["A"].Distance);
            Assert.AreEqual(2, graph["B"].Distance);
            Assert.AreEqual(1, graph["C"].Distance);
            Assert.AreEqual(0, graph["D"].Distance);
            Assert.AreEqual(3, way.Count);
            Assert.AreEqual("A", way[0].Src.Id);
            Assert.AreEqual("B", way[0].Dst.Id);
            Assert.AreEqual("B", way[1].Src.Id);
            Assert.AreEqual("C", way[1].Dst.Id);
            Assert.AreEqual("C", way[2].Src.Id);
            Assert.AreEqual("D", way[2].Dst.Id);
        }
    }
}
